unit oMasterManager;

{
	created   2.3.2010
	author   	Michal Varga
	purpose   controls the communication between the other managers
            knows, which manager is responsible for specific code
            creates all the other managers

	edit list:
                1) 6.3.2010 Michal Varga
                        removed Language manager from the managers list
        comment list:
                6.3. Michal Varga
                        how does it work in delphi constructor, isn't it needed to
                        call ancestor's constructor, even if it is empty? cause someone
                        has commented on the "inherited" line..
        to-do list:
                8.3. Michal Varga
                        try-except block needed, cause PedestriansManager raises exceptions
}

interface

uses
  oManager, oProjectManager, oTreeManager,
  oProcessItem, SysUtils, ComCtrls, oPedestriansManager, oPathsManager,
  oLoadManager, oSaveManager, oEditorManager, oSceneManager, oArrivalsManager,
  oConversionManager, oEditorFLManager, oEditorLLManager, oEditorArrivalManager,
  oEditorPedestrianManager, oEditorPathsManager, oEditorGeneratorManager,
  oEditorRunPropertiesManager, oRunPropertiesManager, oEditorStatisticsManager,
  oConfigManager, oEditorLEManager, oSimulationRenderer;

type
  EMasterManager = class(Exception)
  end;

  tMasterManager = class(tManager)
    private

      aSceneManager : TSceneManager;
      aSaveManager : TSaveManager;
      aLoadManager : TLoadManager;
      aProjectManager : TProjectManager;
      aTreeManager : TTreeManager;
      aPedestrianManager: TPedestrianManager;
      aPathsManager : TPathsManager;
      aArrivalsManager: TArrivalsManager;
      aConversionManager: TConversionManager;
      aRunPropertiesManager: TRunPropertiesManager;
      aCongigManager: TConfigManager;
      aEditorFLManager: TEditorFLManager;
      aEditorLLManager: TEditorLLManager;
      aEditorPathsManager: TEditorPathsManager;
      aEditorPedManager : TEditorPedestrianManager;
      aEditorArrivalManager : TEditorArrival;
      aEditorGeneratorManager: TEditorGeneratorManager;
      aEditorRunPropManager: TEditorRunPropertiesManager;
      aEditorLEManager: TEditorLEManager;
      aEditorManager : TEditorManager;
      aEditorStatisticManager : TEditorStatisticsManager;
      aSimRenderer : TSimulationRenderer;
    public
      property EditorManager: TEditorManager read aEditorManager;
      property PedestriansManager: TPedestrianManager read aPedestrianManager;
      property ProjectManager: TProjectManager read aProjectManager;
      property PathsManager: TPathsManager read aPathsManager;
      property SceneManager: TSceneManager read aSceneManager;
      property ArrivalsManager: TArrivalsManager read aArrivalsManager;
      property SimRenderer: TSimulationRenderer read aSimRenderer;
      constructor create();
      destructor Destroy; override;
      function ProcessObject(paItem: TProcessItem): TProcessItem; override;
      class function EntityProcessObject(paItem: TProcessItem): TProcessItem;
      class function getStaticMaster: TMasterManager;
  end;

implementation

{ tMasterManager }

uses
  oProcessObjectConstants, oProcessObjects, Dialogs, oLogicalEntity;

var
  staticMaster: tMasterManager;

resourcestring masterbadcall = 'bad call of process object';
resourcestring masternotexists = 'master not found';

constructor tMasterManager.create();
begin
  inherited create(self);
  aSceneManager := TSceneManager.Create(Master);
  aLoadManager := TLoadManager.Create(Master);
  aSaveManager := TSaveManager.Create(Master);
  aProjectManager := TProjectManager.Create(Master);
  aTreeManager := TTreeManager.Create(Master);
  aPedestrianManager :=  TPedestrianManager.Create(Master);
  aArrivalsManager := TArrivalsManager.create(Master);
  aPathsManager := TPathsManager.Create(Master);
  aEditorManager := TEditorManager.create(Master);
  aConversionManager := TConversionManager.create(Master);
  aRunPropertiesManager := TRunPropertiesManager.Create(Master);
  aCongigManager := TConfigManager.Create(Master);
  aEditorFLManager := TEditorFLManager.create(Master);
  aEditorLLManager := TEditorLLManager.create(Master);
  aEditorPathsManager := TEditorPathsManager.create(Master);
  aEditorPedManager := TEditorPedestrianManager.Create(Master);
  aEditorArrivalManager := TEditorArrival.create(Master);
  aEditorGeneratorManager := TEditorGeneratorManager.Create(Master);
  aEditorRunPropManager := TEditorRunPropertiesManager.Create(Master);
  aEditorLEManager := TEditorLEManager.create(Master);
  aEditorStatisticManager := TEditorStatisticsManager.create(Master);
  aSimRenderer := TSimulationRenderer.create(Master);
  StaticMaster := self;
end;

destructor tMasterManager.Destroy;
begin
  aEditorPedManager.Free;
  aSceneManager.Free;
  aLoadManager.Free;
  aSaveManager.Free;
  aProjectManager.Free;
  aTreeManager.Free;
  aPedestrianManager.Free;
  aPathsManager.Free;
  aEditorManager.Free;
  aConversionManager.Free;
  aRunPropertiesManager.Free;
  aCongigManager.Free;
  aEditorFLManager.Free;
  aEditorLLManager.Free;
  aEditorArrivalManager.Free;
  aEditorPathsManager.Free;
  aEditorGeneratorManager.Free;
  aEditorRunPropManager.Free;
  aEditorLEManager.Free;
  aSimRenderer.Free;
  StaticMaster := nil;
  inherited;
end;

class function tMasterManager.EntityProcessObject(paItem: TProcessItem): TProcessItem;
begin
  try
//    if not(paItem.Data is TProcessingLogicalEntity) then raise EMasterManager.Create(masterbadcall);
//    if (paItem.Data as TProcessingLogicalEntity).Entity = nil then raise EMasterManager.Create(masterbadcall);
    if getStaticMaster = nil then raise EMasterManager.Create(masternotexists);
    result := getStaticMaster.processobject(paItem);
  except
    on E: EMasterManager do MessageDlg(E.Message,mtError,[mbOK],0);
  end;
end;

function tMasterManager.ProcessObject(paItem: TProcessItem): TProcessItem;
begin

  case paItem.Code of
    PO_TEST : Result := aSceneManager.ProcessObject(paItem);
    PO_PROJECT_DELETE : Result := aProjectManager.ProcessObject(paItem);
    PO_PROJECT_DELETE_PHYS_LAYER : Result := aProjectManager.ProcessObject(paItem);
    PO_PROJECT_DELETE_LOG_LAYER : Result := aProjectManager.ProcessObject(paItem);
    PO_PROJECT_SAVE_SCENE : Result := aProjectManager.ProcessObject(paItem);
    PO_PROJECT_INSERT_PHYS_LAYER: Result := aProjectManager.ProcessObject(paItem);
    PO_PROJECT_INSERT_LOG_LAYER : Result := aProjectManager.ProcessObject(paItem);
    PO_PROJECT_SAVE : Result := aProjectManager.ProcessObject(paItem);
    PO_PROJECT_SAVE_WITH_PATH : Result := aProjectManager.ProcessObject(paItem);
    PO_PROJECT_LOAD : Result := aProjectManager.ProcessObject(paItem);
    PO_PROJECT_INSERT : Result := aProjectManager.ProcessObject(paItem);
    PO_PROJECT_CONFIG_INSERT : Result := aProjectManager.ProcessObject(paItem);
    PO_PROJECT_CONFIG_DELETE : Result := aProjectManager.ProcessObject(paItem);
    PO_PROJECT_SAVE_PEDESTRIANS,
    PO_PROJECT_LOAD_PEDESTRIANS,
    PO_PROJECT_LOAD_SCENE,
    PO_PROJECT_SAVE_PATHS,
    PO_PROJECT_LOAD_PATHS,
    PO_PROJECT_INSERT_PATHS,
    PO_PROJECT_DELETE_PATHS,
    PO_PROJECT_INSERT_ARRIVAL,
    PO_PROJECT_DELETE_ARRIVAL,
    PO_PROJECT_SAVE_ARRIVALS,
    PO_PROJECT_GET_NAME,
    PO_PROJECT_GET_LAYERS,
    PO_PROJECT_INSERT_LAYER_MAPPING,
    PO_PROJECT_SAVE_LAYER,
    PO_PROJECT_GET_LAYER_PATH,
    PO_PROJECT_GET_PATH_NAMES,
    PO_PROJECT_GET_PEDESTRIAN_NAMES,
    PO_PROJECT_SAVE_LOG_LAYER,
    PO_PROJECT_SAVE_PHYS_LAYER,
    PO_PROJECT_SAVE_CONFIGS,
    PO_PROJECT_SAVE_RUN_PROPS,
    PO_PROJECT_LOAD_CONFIGS,
    PO_PROJECT_LOAD_RUN_PROPS,
    PO_PROJECT_INSERT_PEDESTRIANS,
    PO_PROJECT_DELETE_PEDESTRIANS,
    PO_PROJECT_UPDATE_PHYS_LAYER,
    PO_PROJECT_UPDATE_LOG_LAYER,
    PO_PROJECT_GET_ARRIVAL_XML,
    PO_PROJECT_INSERT_ARRIVALS_GROUP,
    PO_PROJECT_ARRIVALS_NAME,
    PO_PROJECT_LOAD_ARRIVALS_GROUP,
    PO_PROJECT_CLOSE_XML,
    PO_PROJECT_DELETE_ARRIVALS_GROUP,
    PO_PROJECT_UNLOAD_ARRIVALS_GROUP,
    PO_PROJECT_LOAD_ARRIVAL,
    PO_PROJECT_GET_PEDESTRIAN_GROUP_ID  : Result := aProjectManager.ProcessObject(paItem);


    // save manager
    PO_SAVEMAN_PREPARE_SAVE, PO_SAVEMAN_SAVE_DATA : Result := aSaveManager.ProcessObject(paItem);

    PO_LOADMAN_LOAD_DATA : Result := aLoadManager.ProcessObject(paItem);



    // world manager
    PO_SCENE_INSERT_PHYSICAL_ENTITY : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_DELETE_PHYSICAL_ENTITY : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_MOVE_PHYSICAL_ENTITY : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_INSERT_LOGICAL_ENTITY_TO_PHYS_ENTITY : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_DELETE_LOGICAL_ENTITY : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_UPDATE_LOGICAL_ENTITY : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_GET_PHYSICAL_ENTITIES_FOR_PEDESTRIAN : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_GET_LOGICAL_ENTITIES_FOR_PEDESTRIAN : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_GET_PEDESTRIANS_FOR_PED_PEDESTRIAN : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_INSERT_PEDESTRIAN : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_MOVE_PEDESTRIAN : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_DELETE_PEDESTRIAN : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_GET_PHYSICAL_ENTITY : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_GET_LOGICAL_ENTITY : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_SAVE : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_LOAD : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_DELETE_LAYER : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_INSERT_LAYER : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_GET_ACTUAL_LEVEL : Result := aSceneManager.ProcessObject(paItem);
    PO_SCENE_GET_ENTITY_BY_ID,
    PO_SCENE_SET_ID,
    PO_SCENE_GET_ID,
    PO_SCENE_INSERT_WAYPOINT,
    PO_SCENE_DELETE_WAYPOINT,
    PO_SCENE_GET_WAYPOINT,
    PO_SCENE_LOAD_PHYS_LAYER,
    PO_SCENE_INSERT_LOGICAL_ENTITY,
    PO_SCENE_SAVE_LAYER,
    PO_SCENE_SET_PATH,
    PO_SCENE_LOAD_LOG_LAYER,
    PO_SCENE_UNLOAD_PHYS_LAYER,
    PO_SCENE_UNLOAD_LOG_LAYER,
    PO_SCENE_GET_LEVEL,
    PO_SCENE_UPDATE_LAYER,
    PO_SCENE_SAVE_ACTUAL_LAYER : Result := aSceneManager.ProcessObject(paItem);

    // ped editor manager
    PO_EDITOR_PED_INSERT,
    PO_EDITOR_PED_EDIT : Result := aEditorPedManager.ProcessObject(paItem);

    // arrival manager
    PO_EDITOR_ARRIVAL_INSERT,
    PO_EDITOR_ARRIVAL_EDIT,
    PO_EDITOR_ARRIVAL_GET : Result := aEditorArrivalManager.ProcessObject(paItem);

    // tree manager
    PO_TREE_INSERT_PHYS_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_PHYS_LAYER_FAST : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_LOG_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_LOG_LAYER_FAST : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_PATHS_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_PATHS_LAYER_FAST : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_PEDEST_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_PEDEST_LAYER_FAST : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_ARRIVALS_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_ARRIVALS_LAYER_FAST : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_RUNPROP_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_RUNPROP_LAYER_FAST : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_CONFIG_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_INSERT_CONFIG_LAYER_FAST : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_LEFT_CLICK : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_RIGHT_CLICK : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_MENU_DEL_CLICK : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_SET_COMPONENT : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_SHOW_PROJECT : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_CLEAR : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_CAN_BE_CREATED_NEW_LL : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_CAN_BE_CREATED_NEW_PATH : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_REMOVE_PHYS_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_REMOVE_LOG_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_REMOVE_PATHS_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_REMOVE_PEDEST_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_REMOVE_ARRIVALS_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_REMOVE_RUNPROP_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_REMOVE_CONFIG_LAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_SET_CHECKED : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_GET_CHECKED : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_REFRESH_PATHS_SUBLAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_REFRESH_PEDEST_SUBLAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_REFRESH_ARRIVALS_SUBLAYER : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_CAN_BE_CREATED_NEW_SUBPATH : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_CAN_BE_CREATED_NEW_SUBPED : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_CAN_BE_CREATED_NEW_SUBARRIVAL : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_MENU_INSERT_CLICK : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_LEFT_DOUBLE_CLICK : Result := aTreeManager.ProcessObject(paItem);
    PO_TREE_REMOVE_SELECTED_LAYER : Result := aTreeManager.ProcessObject(paItem);

    // Pedestrian manager
    PO_PEDMAN_INSERT: Result := aPedestrianManager.ProcessObject(paItem);
    PO_PEDMAN_REMOVE: Result := aPedestrianManager.ProcessObject(paItem);
    PO_PEDMAN_EDIT: Result := aPedestrianManager.ProcessObject(paItem);
    PO_PEDMAN_SAVE: Result := aPedestrianManager.ProcessObject(paItem);
    PO_PEDMAN_LOAD: Result := aPedestrianManager.ProcessObject(paItem);
    PO_PEDMAN_GET_PEDSTRIAN,
    PO_PEDMAN_EXISTS,
    PO_PEDMAN_UNLOAD,
    PO_PEDMAN_GET_NAMES : Result := aPedestrianManager.ProcessObject(paItem);

    // Paths manager
    PO_PATHS_INSERT_PATH : Result := aPathsManager.ProcessObject(paItem);
    PO_PATHS_REMOVE_PATH : Result := aPathsManager.ProcessObject(paItem);
    PO_PATHS_INSERT_WAYPOINT : Result := aPathsManager.ProcessObject(paItem);
    PO_PATHS_REMOVE_WAYPOINT : Result := aPathsManager.ProcessObject(paItem);
    PO_PATHS_SAVE : Result := aPathsManager.ProcessObject(paItem);
    PO_PATHS_LOAD : Result := aPathsManager.ProcessObject(paItem);
    PO_PATHS_GET_PATH,
    PO_PATHS_GET_PATH_NAMES : Result := aPathsManager.ProcessObject(paItem);
    PO_EDITOR_PATHS_CANCEL : Result := aPathsManager.ProcessObject(paItem);
    PO_PATHS_UNLOAD : Result := aPathsManager.ProcessObject(paItem);

    // Arrivals Manager
    PO_ARRMAN_INSERT,
    PO_ARRMAN_EDIT,
    PO_ARRMAN_UNLOAD,
    PO_ARRMAN_UNLOAD_ARRIVAL,
    PO_ARRMAN_LOAD,
    PO_ARRMAN_SAVE,
    PO_ARRMAN_ACTIVATE,
    PO_ARRMAN_EXISTS,
    PO_ARRMAN_GET_NAMES : Result := aArrivalsManager.ProcessObject(paItem);

    // Save/load generatorov
    SAVE_GENERATOR: Result := aSaveManager.ProcessObject(paItem);
    LOAD_GENERATOR: Result := aLoadManager.ProcessObject(paItem);
    
    //Conversions Manager
    CONVERT_DATA_TO_GENERATOR: Result := aConversionManager.ProcessObject(paItem);

    PO_EDITOR_FL_NEW_FRM: Result := aEditorFLManager.ProcessObject(paItem);
    PO_EDITOR_FL_LOAD_FRM: Result := aEditorFLManager.ProcessObject(paItem);
    PO_EDITOR_FL_SAVE,
    PO_EDITOR_FL_SET_ID,
    PO_EDITOR_FL_SET_LEVEL,
    PO_EDITOR_FL_CANCEL : Result := aEditorFLManager.ProcessObject(paItem);

    // Editor LL Manager
    PO_EDITOR_LL_NEW_FRM: Result := aEditorLLManager.ProcessObject(paItem);
    PO_EDITOR_LL_LOAD_FRM: Result := aEditorLLManager.ProcessObject(paItem);
    PO_EDITOR_LL_SAVE,
    PO_EDITOR_LL_SET_ID,
    PO_EDITOR_LL_SET_LEVEL,
    PO_EDITOR_LL_CANCEL,
    PO_EDITOR_LL_CLOSE : Result := aEditorLLManager.ProcessObject(paItem);

    // Editor Pahs Manager
    PO_EDITOR_PATHS_NEW_FRM: Result := aEditorPathsManager.ProcessObject(paItem);
    PO_EDITOR_PATHS_LOAD_FRM: Result := aEditorPathsManager.ProcessObject(paItem);
    PO_EDITOR_PATHS_SAVE: Result := aEditorPathsManager.ProcessObject(paItem);

    // Editor Run Properties Manager
    PO_RUNPROP_EDITOR_INSERT: Result := aEditorRunPropManager.ProcessObject(paItem);
    PO_RUNPROP_EDITOR_EDIT: Result := aEditorRunPropManager.ProcessObject(paItem);
    PO_RUNPROP_EDITOR_GET: Result := aEditorRunPropManager.ProcessObject(paItem);

    // Run Properties manager
    PO_RUNPROPMAN_INSERT: Result := aRunPropertiesManager.ProcessObject(paItem);
    PO_RUNPROPMAN_REMOVE: Result := aRunPropertiesManager.ProcessObject(paItem);
    PO_RUNPROPMAN_EDIT: Result := aRunPropertiesManager.ProcessObject(paItem);
    PO_RUNPROPMAN_SAVE: Result := aRunPropertiesManager.ProcessObject(paItem);
    PO_RUNPROPMAN_LOAD: Result := aRunPropertiesManager.ProcessObject(paItem);
    PO_RUNPROPMAN_GET_RUN_PROPERTIES: Result := aRunPropertiesManager.ProcessObject(paItem);
    PO_RUNPROPMAN_GET_NAMES: Result := aRunPropertiesManager.ProcessObject(paItem);
    PO_RUNPROPMAN_EXISTS: Result := aRunPropertiesManager.ProcessObject(paItem);

    // Config Manager
    PO_CONFIG_INSERT: Result := aCongigManager.ProcessObject(paItem);
    PO_CONFIG_GET_CONFIG: Result := aCongigManager.ProcessObject(paItem);
    PO_CONFIG_SAVE: Result := aCongigManager.ProcessObject(paItem);
    PO_CONFIG_LOAD: Result := aCongigManager.ProcessObject(paItem);
    PO_CONFIG_GET_NAMES: Result := aCongigManager.ProcessObject(paItem);
    PO_CONFIG_REMOVE: Result := aCongigManager.ProcessObject(paItem);
    PO_CONFIG_UNLOAD : Result := aCongigManager.ProcessObject(paItem);

    // EDITOR STATISTIC MANAGER
    PO_EDITOR_STAT_SET_PARAMS,
    PO_EDITOR_STAT_SHOW,
    PO_EDITOR_STAT_SAVE,
    PO_EDITOR_STAT_LOAD,
    PO_EDITOR_STAT_COMPUTE : Result := aEditorStatisticManager.ProcessObject(paItem);

    //editor logical entity manager
    PO_EDLEMAN_EDIT,
    PO_EDLEMAN_SHOW,
    PO_EDLEMAN_HIDE: result := aEditorLEManager.ProcessObject(paItem);

    // SIM RENDERER
    PO_SIM_RENDERER_SHOW,
    PO_SIM_RENDERER_START,
    PO_SIM_RENDERER_PAUSE,
    PO_SIM_RENDERER_STOP,
    PO_SIM_RENDERER_CLOSE,
    PO_SIM_RENDERER_INC_TIME,
    PO_SIM_RENDERER_DEC_TIME,
    PO_SIM_RENDERER_INC_PERIOD,
    PO_SIM_RENDERER_DEC_PERIOD,
    PO_SIM_RENDERER_ENABLE_OUTPUT,
    PO_SIM_RENDERER_DISABLE_OUTPUT: Result := aSimRenderer.PRocessObject(paItem);


    // EDITOR GENERATOR MANAGER

    {PO_GEN_EDITOR_INSERT,
    PO_GEN_EDITOR_EDIT,
    PO_GEN_EDITOR_GET : aEditorGeneratorManager.Processobject(paItem);} //zly manazer!!!!

    // pedestrian manager
//    PO_PREPARE_SAVE_PEDESTRIANS : Result := aPedestrianManager.ProcessObject(paItem);
//    PO_PREPARE_LOAD_PEDESTRIANS : Result := aPedestrianManager.ProcessObject(paItem);
    // waypoint manager
//    PO_PREPARE_SAVE_WAYPOINTS : Result := aWaypointManger.ProcessObject(paItem);
//    PO_PREPARE_LOAD_WAYPOINTS : Result := aWaypointManger.ProcessObject(paItem);

    PO_EDITOR_GET_PEDESTRIANS : Result := aEditorManager.ProcessObject(paItem);

    PO_GET_GENERATOR: Result := aEditorGeneratorManager.ProcessObject(paItem);
    else raise EMasterManager.Create('not a valid processing code : ' + IntToStr(paItem.Code));
  end;
end;

class function tMasterManager.getStaticMaster: TMasterManager;
begin
  Result := staticMaster;
end;

initialization

  staticMaster := nil;

finalization

  staticMaster := nil;

end.
